#include <vector>

using namespace std;

class Solution
{
public:
    vector<vector<int>> generate(int numRows)
    {
        vector<vector<int>> ret;
        ret.resize(numRows);
        for (int i = 0; i < numRows; ++i)
        {
            for (int j = 0; j <= i; j++)
            {
                ret[i].resize(i + 1);
                if (j == 0 || i == j)
                {
                    ret[i][j] = 1;
                }
                else
                {
                    ret[i][j] = ret[i - 1][j] + ret[i - 1][j - 1];
                }
            }
        }
        return ret;
    }
};